package com.xinghou.platform.dao.main.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.xinghou.platform.dao.bases.JdbcTemplate;
import com.xinghou.platform.dao.bases.database.CustomerContextHolder;
import com.xinghou.platform.model.main.Occupation;

@Repository
public class OccupationDAOImpl  {/*
	@Resource
	private JdbcTemplate jdbcTemplate;
	
	@Override
	public Occupation getOccupationById(Integer id) throws DataAccessException {
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_READ);
		String sql = "SELECT Id,name FROM occupation WHERE Id = ?";
		Occupation occupation = jdbcTemplate.queryForObject(sql, new Object[] { id }, new OccupationMapper());
		CustomerContextHolder.clearCustomerType();
		return occupation;
	}

	@Override
	public List<Occupation> getOccupationList() throws DataAccessException {
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_READ);
		String sql = "SELECT Id,name FROM occupation";
		List<Occupation> list = jdbcTemplate.query(sql, new OccupationMapper());
		CustomerContextHolder.clearCustomerType();
		return list;
	}
	
	private static final class OccupationMapper implements RowMapper<Occupation> {
		public Occupation mapRow(ResultSet rs, int rowNum) throws SQLException {
			Occupation occupation = new Occupation();
			occupation.setId(rs.getInt("Id"));
			occupation.setName(rs.getString("name"));
			return occupation;
		}
	}
		*/

}
